package Tool;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MySQL_Refresh_Staffidmirro {
    public static void refreshStaffid(Connection conn) throws SQLException {
        //定义sql
        //查询
        String sql1 = "SET @auto_id = 0;";
        String sql2 = "UPDATE staffsystem.staff SET id = (@auto_id := @auto_id +1) where staffsystem.staff.id;";
        String sql3 = "ALTER TABLE staffsystem.staff AUTO_INCREMENT = 1;";

        //获取执行sql的对象 Stamant
        Statement stmt = conn.createStatement();

        //执行sql
        stmt.execute(sql1);
        stmt.executeUpdate(sql2);
        stmt.execute(sql3);
        //处理结果

    }
}
